package com.smartleanx.module.hrm.mq.bpm;

import com.smartleanx.module.hrm.app.empRisk.EmployeeRiskHandleService;
import com.smartleanx.module.hrm.eums.risk.RiskTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Collections;

/**
 * 员工合同创建完成监听
 *
 * @author xzq
 * @since 2025/8/14
 */
@Slf4j
@Component
public class HrmContractConsumer {

    @Resource
    @Lazy
    private EmployeeRiskHandleService employeeRiskHandleService;

    @RabbitListener(queues = "HRM_CONTRACT_ARCHIVING_QUEUE")
    public void handleHrmContractEvent(String empId) {
        try {
            System.out.println("已接受风险点处理推送===111=："+empId);
            employeeRiskHandleService.execute(Collections.singleton(Long.parseLong(empId)), RiskTypeEnum.SOCIAL_SECURITY_PAYMENT.getCode());
            employeeRiskHandleService.execute(Collections.singleton(Long.parseLong(empId)), RiskTypeEnum.LABOR_CONTRACT.getCode());
            employeeRiskHandleService.execute(Collections.singleton(Long.parseLong(empId)), RiskTypeEnum.LABOR_CONTRACT_EXPIRATION.getCode());
            employeeRiskHandleService.execute(Collections.singleton(Long.parseLong(empId)), RiskTypeEnum.PROBATION_PERIOD.getCode());

        } catch (Exception ex) {
            log.error("[BpmStatusEventConsumer:handleBpmStatusEvent]", ex);
        }
    }
}
